import React, { Component } from 'react';
import { Input, InputProps } from 'antd';
import classnames from 'classnames';

import styles from './index.less';

/**
 * 解决type='number'时maxLength无法使用的情况
 * 移除type='number'时的上下箭头
 */
export default class CustomInputNumber extends Component<InputProps> {
  render() {
    const { className } = this.props;
    return (
      <Input
        className={classnames(styles.custom_input, className)}
        {...this.props}
        type={undefined}
        onInput={(e) => {
          e.currentTarget.value = e.currentTarget.value.replace(/[^\d]/g, '');
        }}
      />
    );
  }
}
